package com.lgs.demo.customview;

import android.content.Context;
import android.content.res.TypedArray;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.AttributeSet;

import com.lgs.demo.R;

/**
 * Created by lgs on 2018/3/2.
 */

public class GoodsNumberPicker extends android.support.v7.widget.AppCompatTextView {

    public GoodsNumberPicker(Context context) {
        this(context, null);
    }

    public GoodsNumberPicker(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public GoodsNumberPicker(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context, attrs);
        //        TypedArray attr =
    }

    private void init(Context context, AttributeSet attrs) {
        TypedArray attr = context.obtainStyledAttributes(attrs, R.styleable.GoodsNumberPicker);
        boolean isShow = attr.getBoolean(R.styleable.GoodsNumberPicker_showDialog, false);
        attr.recycle();
        isShowDialog(isShow);
        // TODO: 2018/3/2
    }

    public void isShowDialog(boolean isShow) {
        if (isShow) {
            ShowDialogFragment dialogFragment = ShowDialogFragment.getInstance();
            dialogFragment.show(mFragment.getFragmentManager(), "");
        }
    }

    private Fragment mFragment;

    public void setFragment(Fragment fragment) {
        mFragment = fragment;
    }


}
